﻿namespace DomainServices.Tools.Pdb.SymStore
{
    using System;
    using System.Diagnostics.SymbolStore;
    using System.Text;

    internal class SymVariable : ISymbolVariable
    {
        private ISymUnmanagedVariable m_unmanagedVariable;

        internal SymVariable(ISymUnmanagedVariable variable)
        {
            if (variable == null)
            {
                throw new ArgumentNullException("variable");
            }
            this.m_unmanagedVariable = variable;
        }

        public byte[] GetSignature()
        {
            int num;
            this.m_unmanagedVariable.GetSignature(0, out num, null);
            byte[] sig = new byte[num];
            this.m_unmanagedVariable.GetSignature(num, out num, sig);
            return sig;
        }

        public int AddressField1
        {
            get
            {
                int num;
                this.m_unmanagedVariable.GetAddressField1(out num);
                return num;
            }
        }

        public int AddressField2
        {
            get
            {
                int num;
                this.m_unmanagedVariable.GetAddressField2(out num);
                return num;
            }
        }

        public int AddressField3
        {
            get
            {
                int num;
                this.m_unmanagedVariable.GetAddressField3(out num);
                return num;
            }
        }

        public SymAddressKind AddressKind
        {
            get
            {
                int num;
                this.m_unmanagedVariable.GetAddressKind(out num);
                return (SymAddressKind) num;
            }
        }

        public object Attributes
        {
            get
            {
                int num;
                this.m_unmanagedVariable.GetAttributes(out num);
                return num;
            }
        }

        public int EndOffset
        {
            get
            {
                int num;
                this.m_unmanagedVariable.GetEndOffset(out num);
                return num;
            }
        }

        public string Name
        {
            get
            {
                int num;
                this.m_unmanagedVariable.GetName(0, out num, null);
                StringBuilder szName = new StringBuilder(num);
                this.m_unmanagedVariable.GetName(num, out num, szName);
                return szName.ToString();
            }
        }

        public int StartOffset
        {
            get
            {
                int num;
                this.m_unmanagedVariable.GetStartOffset(out num);
                return num;
            }
        }
    }
}

